import { CONTENT_LIST_DATA } from './actionsTypes';
import { CHANGEREADYSTATE } from '../../../components/scrollView/scrollAction'
import api from '../../../http/api.js';

export const getContentListData = (obj) => {
  return {
    type: CONTENT_LIST_DATA,
    obj
  }
}

const getContentList = (page) => {

  return (dispatch) => {
      dispatch({
          type: CHANGEREADYSTATE,
          obj: false
      });
    api.getContentList({
      page: page || 0
    }).then((res) => {
      dispatch(getContentListData({
        list: res.data.poilist,
        page: page
      }))
        dispatch({
            type: CHANGEREADYSTATE,
            obj: true
        });
    })
  }
}


export default getContentList;
